$(function () {
    $.ajax({
        url: "/getUser",
        method: "get",
        dataType: "json",
        success: function (rs) {
            if (rs.user != null) {
                $(".user").append("欢迎你：" + rs.user.username + "，<a href='#' onclick='logout()'>注销</a>");
                //个人信息填入
                $("input[name='username']").val(rs.user.username);
                $("input[name='login']").val(rs.user.login);
                $("input[name='password']").val(rs.user.password);
                $("input[name='name']").val(rs.user.name);
                $("input[name='sex']").val(rs.user.sex);
                $("input[name='created']").val(new Date(rs.user.created));
                $("input[name='address']").val(rs.user.address);
                $("input[name='phone']").val(rs.user.phone);
                $("#head_pic").attr("src", rs.user.headPic);
                console.log(rs)
            } else {
                //$(".user").append("<a href='#' onclick='showLogin()'>登录</a>查看更多内容");
                alert("请先登录查看个人中心");
                window.location = "/foodCity"
            }
        }
    });
})